﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PraxisRent.Entities;
using PraxisRent.Repository;
using Microsoft.Practices.Unity;

namespace PraxisRent.BL
{
    public class PagoBL:IPagoBL
    {
        [Dependency]
        public IPagoRepository pagoDAO { get; set; }

        public List<PAGO> GetAllFromPago()
        {
            return pagoDAO.GetAllFromPago();
        }

        public List<PAGO> GetAllFromPagoByIdCredito(int id)
        {
            return pagoDAO.GetAllFromPagoByIdCredito(id);
        }

        public PAGO GetAllFromPagoById(int id)
        {
            return pagoDAO.GetAllFromPagoById(id);
        }

        public void AddPago(PAGO pago)
        {
            pagoDAO.AddPago(pago);
        }

        public void UpdatePago(PAGO pago)
        {
            var msg = "";
            var ok = pago.Validate(out msg);

            if (ok)
            {
                pagoDAO.UpdatePago(pago);
            }
            else
            {
                throw new Exception(msg);
            }
        }

        public List<PAGO> GetAllFromPagoByIdCreditoAndCancelados(int id)
        {
            return pagoDAO.GetAllFromPagoByIdCreditoAndCancelados(id);
        }
    }
}
